<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>教学班管理</title>
		<!-- Bootstrap Styles-->
		<link href="../../css/bootstrap/bootstrap.css" rel="stylesheet" />
		<!-- FontAwesome Styles-->
		<link href="../../css/font-awesome.css" rel="stylesheet" />
		<!-- Morris Chart Styles-->

		<!-- Custom Styles-->
		<link href="../../css/custom-styles.css" rel="stylesheet" />
		<!-- Google Fonts-->
		<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
		<!-- TABLE STYLES-->
		<link href="../../js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
	</head>

	<body>
		<div id="wrapper">
			<nav class="navbar navbar-default top-navbar" role="navigation">
				<div class="navbar-header">
					<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
					<a class="navbar-brand" href="../teacher/tea_course_index.html">题库与考试</a>
				</div>

				<ul class="nav navbar-top-links navbar-right">

					<li class="dropdown">
						<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
							<i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
						</a>
						<ul class="dropdown-menu dropdown-user">
							<li>
								<a href="../manager/adm_person_index.html"><i class="fa fa-user fa-fw"></i> 个人中心</a>
							</li>
							<li class="divider"></li>
							<li>
								<a href="../../login.html"><i class="fa fa-sign-out fa-fw"></i> 退出登录</a>
							</li>
						</ul>
						<!-- /.dropdown-user -->
					</li>
					<!-- /.dropdown -->
				</ul>

			</nav>
			<!--/. NAV TOP  -->
			<nav class="navbar-default navbar-side" role="navigation">
				<div class="sidebar-collapse">
					<ul class="nav" id="main-menu">

						<li>
							<a href="../manager/adm_index.html"><i class="fa fa-dashboard"></i> 用户角色管理</a>
						</li>
						<li>
							<a href="../manager/adm_infoManage_index.html"><i class="fa fa-desktop"></i> 用户信息管理</a>
						</li>
						<li>
							<a href="../manager/adm_schoolClass_index.html"><i class="fa fa-bar-chart-o"></i> 系部信息管理</a>
						</li>
						<li>
							<a href="../manager/adm_exerciseType_index.html"><i class="fa fa-sitemap"></i> 试题类型管理</a>
						</li>
					</ul>

				</div>

			</nav>
			<!-- /. NAV SIDE  -->
			<div id="page-wrapper">
				<div id="page-inner">
					<div class="row">
						<div class="col-md-12">
							<h1 class="page-header">
           修改个人信息
        </h1></div>
					</div>
					<div class="container" style="width:100%">
						<div class="row">

							<div class="well">
								<ul class="nav nav-tabs">
									<li class="active">
										<a href="#message" data-toggle="tab">个人资料</a>
									</li>
									<li>
										<a href="#profile" data-toggle="tab">密码</a>
									</li>
								</ul>
								<div id="myTabContent" class="tab-content">
									<div class="tab-pane active in" id="message">
										<form class="form-horizontal" role="form" id="tab1">
											<div class="form-group" style="padding-top: 10px">
												<!-- 学号 -->
												<label for="studentID" class="col-sm-2 control-label">工号</label>
												<div class="col-sm-10">
													<label>
                                        				<input type="text" class="form-control" id="studentID" value="" disabled/>
                                        			</label>
												</div>
												<!-- 姓名 -->
												<label for="userName" class="col-sm-2 control-label">姓名</label>
												<div class="col-sm-10">
													<label>
                                        				<input type="text" class="form-control" id="userName" value="" disabled/>
                                        			</label>
												</div>
												<!-- 性别 -->
												<label for="sex1" class="col-sm-2 control-label">性别</label>
												<div class="col-sm-10">
													<!--<input type="radio" class="form-control" id="sex1" value="male" checked>男-->
													<!--<input type="radio" class="form-control" id="sex2" value="female" checked>女-->
													<div class="radio">
														<label>
                                                <input type="radio" name="sex1" id="sex1" value="1" class="gender" checked disabled>男
                                            </label>
													</div>
													<div class="radio">
														<label>
                                                			<input type="radio" name="sex1" id="sex2" value="2" class="gender" checked disabled>女
                                            			</label>
													</div>
												</div>

												<!-- 手机号 -->
												<label for="mobile" class="col-sm-2 control-label">手机号</label>
												<div class="col-sm-10">
													<label>
                                            			<input type="text" class="form-control" id="mobile" value="" />
                                        			</label>
												</div>
											</div>
										</form>
									</div>
									<!-- 输入密码模块输入旧密码匹配通过在进行新的密码的设置,并提示修改成功 -->
									<div class="tab-pane fade" id="profile">
										<form class="form-horizontal" role="form" id="tab2">
											<div class="form-group" style="padding-top: 10px">
												<label for="password1" class="col-sm-2 control-label">旧密码</label>
												<div class="col-sm-10">
													<input type="password" class="form-control" style="width:20%" id="password1" placeholder="请输入新密码">
												</div>
											</div>
											<div class="form-group">
												<label for="password2" class="col-sm-2 control-label">新密码</label>
												<div class="col-sm-10">
													<input type="password" class="form-control" style="width:20%" id="password2" placeholder="请输入新密码">
												</div>
											</div>
											<div class="form-group">
												<div class="col-sm-offset-2 col-sm-10">
													<button type="submit" class="btn btn-primary" style="width:10%" id="changePwd">确定</button>
												</div>
											</div>
										</form>
									</div>
								</div>
							</div>
						</div>
					</div>

					<!-- /. PAGE WRAPPER  -->
					<!-- /. WRAPPER  -->
					<!-- JS Scripts-->
					<!-- jQuery Js -->
					<script src="../../js/jquery-1.10.2.js"></script>
					<!-- Bootstrap Js -->
					<script src="../../js/bootstrap.min.js"></script>
					<!-- Metis Menu Js -->
					<script src="../../js/jquery.metisMenu.js"></script>
					<!-- DATA TABLE SCRIPTS -->
					<script src="../../js/dataTables/jquery.dataTables.js"></script>
					<script src="../../js/dataTables/dataTables.bootstrap.js"></script>
					<script src="../../js/jquerysession.js"></script>
					<script>
						$(document).ready(function() {
							$('#dataTables-example').dataTable();
							fillTable();
						});

						//修改密码
						$('#changePwd').click(function (e) {
							e.preventDefault();

							if(!checkPassword()){
							    alert("输入的密码不一样");
							}else{
                                var user = JSON.stringify({"id":$.session.get("userid"), "password":$("#password2").val()});
							    $.ajax({
									type:'post',
									url:'/user/updateByUserId',
									data:user,
                                    contentType: "application/json",
                                    dataType: "json",
									success:function (data) {
										if (data.msg == "success"){
										    alert("修改成功");
										    $("#password1").val("");
										    $("#password2").val("");
										}else{
										    alert("修改失败");
										    window.location.href="adm_person_index.html";
										}
                                    }
								});
							}

                        });

                        function checkPassword(){

                            return( $("#password1").val()==$("#password2").val() && $("#password1").val()!="");
                        }
						
						function fillTable() {
							$.ajax({
								type:'get',
								url:'/user/findByUserId/' + $.session.get('userid'),
                                contentType: "application/json",
                                dataType: "json",
								success: function (data) {
								    console.log(data);
									$('#studentID').val(data.data.workid);
									$('#userName').val(data.data.username);
									$('#sex1').val(data.data.sex);
									$('#mobile').val(data.data.mobilephone);
                                }
							})
                        }
					</script>
				</div>
			</div>
		</div>
	</body>

</html>